package com.xianyun.book.controller;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.xianyun.book.api.BookServiceI;
import com.xianyun.book.dto.BookSearchQry;
import com.xianyun.book.dto.clientobject.BookInfoCO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 首页管理
 * @author ytt
 */
@RestController
public class IndexController {
    @Autowired
    private BookServiceI bookService;

    /**
     * TODO: 使用elastic数据进行重写 2021/5/30
     * 获取最新上架的书籍
     * @return 书籍集合
     */
    @GetMapping("/new/on/shelf")
    public MultiResponse<BookInfoCO> getBookNewOnShelf(){
        return null;
    }

    /**
     * @// TODO: 使用elastic数据进行重写 2021/5/30
     * 获取最畅销书籍
     * @return 书籍集合
     */
    @GetMapping("/best/selling")
    public MultiResponse<BookInfoCO> getBookBestOnSelling(){
        return null;
    }

    @PostMapping("/open/book/query")
    public PageResponse<BookInfoCO> bookQueryName(BookSearchQry qry){
        return bookService.searchBookListBySort(qry);
    }

    @GetMapping("/open/book/suggest/completion/{searchKey}")
    public MultiResponse<String> bookSearchCompletion(@PathVariable String searchKey){
        return bookService.bookSearchCompletion(searchKey);
    }
}
